<template>
	<view>
		<view>

			<view class="mainContent">

				<view class="main_content_center">
					<view class="contentTitle">
						<text class="hf_yt">标题</text>
						<text class="hf_content">内容</text>
						<text class="hf_size">回复数</text>
						<text class="hf_time">发布时间</text>
						<text class="hf_time">操作</text>
					</view>

					<template v-for="tiezi in datas">
						<view class="contentItem">
							<text class="hf_yt" @click="showTz(tiezi)">{{tiezi.LUNTAN_BIAOTI}}</text>
							<text class="hf_content" @click="showTz(tiezi)">{{getContent(tiezi.LUNTAN_BIAOTI)}}</text>
							<text class="hf_size">{{gethfSize(tiezi.huifu_ids)}}条</text>
							<text class="hf_time">{{gettime(tiezi.LUNTAN_FTSJ)}}</text>
							<text class="hf_caozuo" @click="showTz(tiezi)">查看</text>
						</view>
					</template>

					<pageView ref="pageView"></pageView>

				</view>

			</view>

		</view>
	</view>
</template>

<script>
	import pageView from '../../views/PageView.vue'
	export default {
		components: {
			pageView
		},

		data() {
			return {
				datas: [],
				tjs: [],
				pageType: "U_tieziPage",
				page: 1,
			}
		},
		created() {
			//注册全局监听事件，搜索后更新界面数据
			uni.$on(this.pageType, (page) => {
				this.getMyTz(page);
			})
		},

		mounted() {
			this.$refs.pageView.setType(this.pageType);

			this.$nextTick(() => {

				this.getMyTz(1);
			});

		},

		methods: {
			showTz(lt) {

				//this.addck(cp.CHANPIN_ID);
				uni.navigateTo({
					url: '../luntan/luntanDetail',
					success: function(res) {
						res.eventChannel.emit('showLt', lt)

					}
				})

			},
			getContent(text) {
				if (text.length > 10) {
					return text.substring(0, 15);
				}
				return text;
			},
			gethfSize(hids) {
				if (hids == null) {
					return 0;
				}

				var hfs = new Array();
				hfs = hids.split(",");
				return hfs.length;
			},
			gettime(timeText) {
				return timeText.substring(0, 11);
			},


			async getMyTz(pageNum) {
				this.page = pageNum;
				try {
					const res = await this.$getData({
						url: this.$apis.getUserTzs,
						data: {
							page: pageNum,
							uid: this.$PublicData.getUserdata().uid,
						}
					})
					if (res != null && res.data != null && res.data.data != null
					&& res.data.data.length>1) {
						this.datas = res.data.data;
					}


				} catch (e) {
					console.log("eee: ", e);
				}


			},
		}

	}
</script>

<style>
	. {
		-webkit-box-sizing: border-box; //谷歌浏览器
		-moz-box-sizing: border-box; //火狐浏览器
		box-sizing: border-box;
		margin: 0px;
	}

	.mainContent {
		align-items: center;
		display: flex;
		justify-content: center;
		flex-direction: column;

	}

	.main_content_center {
		min-height: 800px;

	}


	.contentTitle {
		margin-top: 5px;
		align-items: center;
		height: 40px;
		padding-left: 5px;
		padding-right: 5px;
		width: 950px;
		display: flex;
		background: #E5E5E5;
	}

	.contentItem {
		justify-content: center;
		align-items: center;
		height: 50px;
		padding-left: 5px;
		padding-right: 5px;
		width: 950px;
		display: flex;
		border-bottom: 1px solid #E5E5E5;

	}



	.contentItem_content {
		display: flex;
		flex-wrap: wrap;
		overflow: hidden;
		white-space: nowrap;
	}

	.contentItem image {
		width: 20px;
		height: 20px;
	}

	.hf_yt {
		white-space: nowrap;
		display: flex;
		overflow: hidden;
		color: #000000;
		display: flex;
		width: 380px;
	}

	.hf_content {
		white-space: nowrap;
		display: flex;
		overflow: hidden;
		display: flex;
		width: 380px;
	}

	.hf_time {
		color: #333;
		justify-content: center;
		display: flex;
		white-space: nowrap;
		display: flex;
		overflow: hidden;
		width: 112px;
	}

	.hf_caozuo {
		justify-content: center;
		display: flex;
		overflow: hidden;
		width: 102px;
		border-radius: 3px;
		cursor: pointer;

	}

	.hf_size {
		justify-content: center;
		display: flex;
		overflow: hidden;
		width: 112px;

	}

	.hf_caozuo :hover {
		justify-content: center;
		display: flex;
		overflow: hidden;
		width: 102px;
		border-radius: 3px;
		background: #FF8C00;
		color: #FFFFFF;
		cursor: pointer;
	}
</style>
